package com.kaishengit.action;


import java.util.Map;

import org.apache.struts2.interceptor.SessionAware;

import com.kaishengit.pojo.User;
import com.kaishengit.service.UserService;
import com.opensymphony.xwork2.ActionSupport;

public class UserAction extends ActionSupport implements SessionAware{
	
	private static final long serialVersionUID = 1L;
	private UserService userService;
	private User user; 
	private String code;
	private Map<String, Object> session;
	private String password2;
	
	public String save() {
		userService.save(user);
		return SUCCESS;
	}
	
	public String sign_in() {
		session.clear();
		return SUCCESS;
	}
	
	@Override
	public String execute() throws Exception {
		return super.execute();
	}
	

	public String login(){
		User con = userService.login(user);
		if(con != null) {
			//Map<String, Object> session = actionc
			session.put("user", con);
			return SUCCESS;
		}else {
			code = "10001";
			return LOGIN;
		}
	}



	
	
	
	// get  set................................
	






	public String getCode() {
		return code;
	}




	public String getPassword2() {
		return password2;
	}

	public void setPassword2(String password2) {
		this.password2 = password2;
	}

	public UserService getUserService() {
		return userService;
	}


	public void setUserService(UserService userService) {
		this.userService = userService;
	}


	public User getUser() {
		return user;
	}


	public void setUser(User user) {
		this.user = user;
	}


	public void setCode(String code) {
		this.code = code;
	}


	public void setSession(Map<String, Object> session) {
		this.session = session;
	}
	
	
}
